﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace Disk_Pizza_Admin
{
    public partial class frmBackup : Form
    {
        public frmBackup()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            folderBrowserDialog1.ShowDialog();
            txtPath.Text = folderBrowserDialog1.SelectedPath;
        }

        private void btnSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                DirectoryInfo des = new DirectoryInfo(txtPath.Text);
                String dest = des + "/" + "pizzarialadolceitalia" + DateTime.Now.ToString("dd-MM-yyyy") + ".mdb";
                String dir = Application.StartupPath + @"\database.mdb";
                File.Copy(dir, dest);
                MessageBox.Show("Arquivo de backup criado: " + dest);

            }

            catch (Exception ex)
            {
                MessageBox.Show("Erro ao tentar realizar o Backup. - Falha: " + ex.Message.ToString());
            }
        }
    }
}
